<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- //将数字转成字符串 -->
    <script>
        //1. tostring(); 后面加数字转为几进制
        var num = 10;
        
        var a=3;
        console.log(a.toString(2));  //返回字符串100000

        console.log( num.toString(2));
        //2. String ()强制转换
        var number = 10;
        console.log(String(number));
        //3.隐式转换
        var number1 = 20;
        number1 = number1 + "21";
        console.log(number1);
        console.log(typeof number1);

        
        console.log('20'-20,'number1');



        // isInteger//判断是否为整数
        var num3 = 3.4;
        console.log(Number.isInteger(num3));
    </script>
    <!-- 将字符串转为数字 -->
    <script>
        //1.字符串转为整数
        var str = "40";
        var num = (parseInt(str));
        console.log(num);

        //2.字符串转为小数
        var str1 = "3.1415926";
        var num1 = (parseFloat(str1))
        console.log(num1);

        // 3.强制转换
        var str2 = "3.125";
        var num2 = (Number(str2));
        console.log(num2)
    </script>

    <!-- 布尔类型的转换   -->

    <script>
        // 除了 '' 0 null undefined NaN 都是false外 其他都是true 
        console.log(Boolean(2));
        console.log(!!"hello"); //!是把文字转为 false !转为true 隐士转换
    </script>
</head>

<body>

</body>

</html>